<{include file="tpl/header.html"}>
<link rel="stylesheet" href="kindedit/themes/default/default.css" />
<link rel="stylesheet" href="kindedit/plugins/code/prettify.css" />

<h2 class="ytadmin-h2"><{$data_return['update_add']}>文章
<a class="pull-right btn btn-info" href="<{spUrl c=article a=index cat_id=$cat_id}>">返回文章列表</a>
</h2>
<div class="ytadmin-form-wrap clearfix">
	<form class="form-horizontal" role="form" action="<{spUrl c=article a=opera}>" method="post">	
		<div class="form-group">
			<label for="title" class="col-sm-1 control-label">标题：</label>
			<div class="col-sm-6">
				<input type="text" name="title" id="title" class="form-control" placeholder="标题" value="<{$data_return['title']}>"/>
			</div>
		</div>
		<div class="form-group" >
			<label for="cat" class="col-sm-1 control-label">分类：</label>
			<div class="col-sm-11">
				<select name="cat_id" id="cat" class="form-control" style="width:225px;">
					<{foreach key=key item=cat_item from=$cat_result}>
						<{if $data_return['cat_id']==$cat_item['id']}>
							<option value="<{$cat_item['id']}>" selected="selected"><{$cat_item['name']}></option>
						<{else}>
							<option value="<{$cat_item['id']}>"><{$cat_item['name']}></option>
						<{/if}>
					<{/foreach}>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="add_time" class="col-sm-1 control-label">时间：</label>
			<div class="col-sm-6">
				<input type="text" name="add_time" id="add_time" class="form-control ytadmin-input-mid" placeholder="时间" value="<{$data_return['add_time']}>"/>
			</div>
		</div>
		<div class="form-group">
			<label for="description" class="col-sm-1 control-label">简述：</label>
			<div class="col-sm-11">
				<textarea name="description" class="form-control" style="width:916px;height:200px;"><{$data_return['description']}></textarea>
			</div>
		</div>
		<div class="form-group">
			<label for="content" class="col-sm-1 control-label">内容：</label>
			<div class="col-sm-11">
				<textarea name="content" style="width:916px;height:400px;visibility:hidden;"><{$data_return['content']}></textarea>
			</div>
		</div>		
		<div class="form-group">
			<label for="image" class="col-sm-1 control-label">图片：</label>
			<div class="col-sm-11">	
					
				<input type="button" class="btn btn-default pull-left" id="image" value="选择图片" />
				<input type="text" id="url" style="width:836px;"  class="form-control pull-left" name="img_dir" value="<{if $data_return['img_dir']}><{$data_return['img_dir']}><{/if}>" />
				<div id="img_show_box" style="width:916px;height:300px;overflow:scroll;">
					<img id="img_show" src="<{if $data_return['img_dir']}><{$data_return['img_dir']}><{/if}>" />
				</div>
			</div>
		</div>	
		<!--
		<div class="form-group" >
			<label for="pic_cat_id" class="col-sm-1 control-label">相册：</label>
			<div class="col-sm-11">
				<select name="pic_cat_id" id="pic_cat_id" class="pull-left form-control" style="width:225px;">
					<option value="0">无</option>
					<option value="-1">新建相册</option>
					<{foreach key=key item=cat_item from=$pic_cat_result}>
						<{if $data_return['pic_cat_id']==$cat_item['id']}>
							<option value="<{$cat_item['id']}>" selected="selected"><{$cat_item['name']}></option>
						<{else}>
							<option value="<{$cat_item['id']}>"><{$cat_item['name']}></option>
						<{/if}>
					<{/foreach}>
				</select>
				<input type="text" name="pic_cat_name" id="pic_cat_name"  class="hide pull-left form-control ytadmin-input-mid" placeholder="新建相册名称" value="<{$data_return['pic_cat_name']}>"/>
			</div>
		</div>
		-->
		<div class="form-group">
			<input type="hidden" name="update_add" value="<{$data_return['update_add']}>"/>
			<input type="hidden" name="id" value="<{$data_return['id']}>"/>
			<div class="col-sm-offset-1 col-sm-11">
				<input type="submit" name="submit" class="btn btn-info" value="<{$data_return['update_add']}>"/>
			</div>
		</div>
	</form>
</div>

<script charset="utf-8" src="kindedit/kindeditor.js"></script>
<script charset="utf-8" src="kindedit/lang/zh_CN.js"></script>
<script charset="utf-8" src="kindedit/plugins/code/prettify.js"></script>
<script>
	KindEditor.ready(function(K) {
		var editor2 = K.editor({
			allowFileManager : true,
			formatUploadUrl:false,
		});
		K('#image').click(function() {
			editor2.loadPlugin('image', function() {
				editor2.plugin.imageDialog({
					imageUrl : K('#url').val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#url').val(url);
						$('#img_show').attr('src',url);
						editor2.hideDialog();
					}
				});
			});
		});	
			
		var editor1 = K.create('textarea[name="content"]', {
			cssPath : 'kindedit/plugins/code/prettify.css',
			uploadJson : 'kindedit/php/upload_json.php',
			fileManagerJson : 'kindedit/php/file_manager_json.php',
			allowFileManager : true,
			filterMode:false,
			formatUploadUrl:false,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					K('form[name=example]')[0].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					K('form[name=example]')[0].submit();
				});
			}
		});
		prettyPrint();
	});

	$('#pic_cat_id').change(function(){
		if($(this).val()=='-1'){$('#pic_cat_name').removeClass('hide');}
		else{$('#pic_cat_name').addClass('hide');}
	});
</script>

<{include file="tpl/footer.html"}>
